package br.com.sistema.models;

import java.util.Calendar;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Version;

@Entity
@Table(name="pais")
public class Pais {
	
	@Id
	@Column(name="paisid")
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private int paisid;
	
	@Column(name="paisnome", length=50, nullable=false)
	private String paisnome;
	
	@Column(name="paiscodnum", length=5, nullable=false, unique=true)
	private String paiscodnum;
	
	@Column(name="paisalf2", length=2)
	private String paisalf2;
	
	@Column(name="paisalf3", length=3)
	private String paisalf3;

	@Column(name="xdatai", nullable=false)
	@Temporal(TemporalType.TIMESTAMP)
	private Calendar xdatai;
	
	@Column(name="xdatau", nullable=false)
	@Temporal(TemporalType.TIMESTAMP)
	private Calendar xdatau;
	
	@Column(name="xusuario", nullable=false)
	private String xusuario;

	@Version
	@Column(name="xversao")
	private Integer xversao;

	@PrePersist
	public void prePersist(){
		xdatai = Calendar.getInstance();
		xdatau = Calendar.getInstance();
	}
	
	@PreUpdate
	public void preUpdate(){
		xdatau = Calendar.getInstance();
	}
	
	public int getPaisid() {
		return paisid;
	}

	public void setPaisid(int paisid) {
		this.paisid = paisid;
	}

	public String getPaisnome() {
		return paisnome;
	}

	public void setPaisnome(String paisnome) {
		this.paisnome = paisnome;
	}

	public String getPaiscodnum() {
		return paiscodnum;
	}

	public void setPaiscodnum(String paiscodnum) {
		this.paiscodnum = paiscodnum;
	}

	public String getPaisalf2() {
		return paisalf2;
	}

	public void setPaisalf2(String paisalf2) {
		this.paisalf2 = paisalf2;
	}

	public String getPaisalf3() {
		return paisalf3;
	}

	public void setPaisalf3(String paisalf3) {
		this.paisalf3 = paisalf3;
	}

	public String getXusuario() {
		return xusuario;
	}

	public void setXusuario(String xusuario) {
		this.xusuario = xusuario;
	}

}
